# 随机数Demo

import random
import numpy as np

# 生成浮点数 [0,1)
print(random.random())
# 生成[a,b)区间的浮点数
print(random.uniform(10, 20))
# 整数随机数 1-10
print(random.randint(1, 10))
# n选1
print(random.choice(range(60)))

# 标准差和均值
mean, std = 5, 1
# 取值范围
min_value, max_value = 0, 10
# 生成正态分布随机数
random_numbers = np.random.normal(mean, std, 1000)
# 转换成整数
random_ints = np.round(random_numbers).astype(int)
# 归一化
randomints = np.clip(random_ints, min_value, max_value)

val = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for v in randomints:
    val[v] += 1
print(val)
